package com.bj58.mis.apm.server.statistics.conf;

import com.bj58.mis.apm.server.statistics.mock.filter.MockFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;

/**
 * @author: zhangfx
 * @create: 2018-06-08 15:25
 **/
@Configuration
@Profile("mock")
public class MockFilterConfig {
    @Bean
    public MockFilter mockFilter(){
        return new MockFilter();
    }

    @Bean
    public FilterRegistrationBean apmClientFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(mockFilter());//添加过滤器
        registration.addUrlPatterns("/*");//设置过滤路径，/*所有路径
        registration.setName("MockFilter");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);//设置优先级
        return registration;
    }

}
